// packageE/membertool/membertool.js
Component({
  properties: {
    datas: {
      type: null,
    },
    component_id: {
      type: null,
    },
    notShow: {
      type: null,
    },
    member_item: {
      type: null,
    },
  },
  // 私有数据，可用于模板渲染
  data: {
    emptyImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png",

    activeNames: true,
  },
  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached() {},
    moved() {},
    detached() {},
  },

  // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
  attached() {},
  // 此处attached的声明会被lifetimes字段中的声明覆盖
  ready() {},

  methods: {
    errorFunction(event) {
      let index = event.currentTarget.dataset.index;
      let img = 'datas.show_list[' + index + '].image';
      this.setData({
        [img]: 'https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png'
      });
    }, 
    //根据后台返回名字做跳转
    pluginGoto(e) {
      let item = e.currentTarget.dataset.item;
      let url = item.url;
      //跳转到推广中心
      if (item.url == "extension") {
        this.goextension();
        return;
      }

      if (item.name == "courier") {
        wx.setStorage({
          key: "couriername",
          data: item.title,
        });
        wx.navigateTo({
          url: "/packageA/member/" + url + "/" + url,
        });
      } else if (item.name == "supplier") {
        wx.navigateTo({
          url:
            "/packageA/member/" +
            url +
            "/" +
            url +
            "?uid=" +
            this.data.supplier_id,
        });
      } else if (item.url == "HotelManage") {
        wx.navigateTo({
          url:
            "/packageA/hotel/HotelManage/HotelManage?title=" +
            encodeURIComponent("酒店管理"),
        });
      } else if (item.url == "aftersaleslist") {
        this.goaftersaleslist();
      } else if (item.url == "helperLiveList") {
        this.getTemplate();
      } else if (item.name == "m-erweima") {
        this.triggerEvent("openQrCode", "block");
      } else if (item.url == "collageIndex") {
        wx.navigateTo({
          url: "/packageE/member/collage/collageIndex/collageIndex",
        });
      }else {
        console.log(item.mini_url)
        wx.navigateTo({
          url: item.mini_url,
        });
      }

    },
    goaftersaleslist: function () {
      wx.navigateTo({
        url: "/packageD/member/myOrder/Aftersaleslist/Aftersaleslist",
      });
    },
    //跳到收藏页面
    gocollection(e) {
      wx.navigateTo({
        url: "/packageD/member/collection/collection",
      });
    },
    //跳转到足迹
    gofootprint(e) {
      wx.navigateTo({
        url: "/packageD/member/footprint/footprint",
      });
    },
    //跳转到评论页
    gomyEvaluation(e) {
      wx.navigateTo({
        url: "/packageD/member/myEvaluation/myEvaluation",
      });
    },
    //跳转到客户
    gomyRelationship(e) {
      //myRelationship
      wx.navigateTo({
        url: "/packageD/member/myRelationship/myRelationship",
      });
    },
    //跳转到地址
    goaddress(e) {
      wx.navigateTo({
        url: "/packageD/member/addressList/addressList",
      });
    },
    //跳转到优惠
    gocoupon(e) {
      wx.navigateTo({
        url: "/packageA/member/coupon_v2/coupon_v2",
      });
    },
    //跳转到设置
    goinfo(e) {
      wx.navigateTo({
        url: "/packageA/member/info/info",
      });
    },
    //跳到签到页面
    gosign() {
      //sign
      wx.navigateTo({
        url: "/packageA/member/sign/sign",
      });
    },
    //跳转到收银台
    gocashier() {
      wx.navigateTo({
        url: "/packageC/cashier/cashier/cashier",
      });
    },
    //跳转到微店
    gomicroShop_home() {
      wx.navigateTo({
        url: "/packageC/microshop/microShop_home/microShop_home",
      });
      //microShop_home
    },
    //跳转到我要开店
    gomicroShop_apply() {
      //microShop_apply
      wx.navigateTo({
        url: "/packageC/microshop/microShop_apply/microShop_apply",
      });
    },
    //跳转到华侨币
    gooverseas_index() {
      //overseas_index
      wx.navigateTo({
        url: "/packageB/member/overseas_index/overseas_index",
      });
    },
    //跳转到门店管理
    gostoreManage() {
      wx.navigateTo({
        url: "/packageC/o2o/storeManage/storeManage",
      });
      //storeManage
    },
    //跳装到帮助页面
    gohelpcenter() {
      wx.navigateTo({
        url: "/packageB/member/helpcenter/helpcenter",
      });
    },
    //跳装到冻结币
    goFrozenCoin() {
      //FrozenCoin
      wx.navigateTo({
        url: "/packageB/member/FrozenCoin/FrozenCoin",
      });
    },
    //跳到爱心兑换值
    golove_index: function () {
      //love_index
      wx.navigateTo({
        url: "/packageB/member/love/Love_index/Love_index",
      });
    },
    goextension: function () {
      //extension
      wx.reLaunch({
        url: "/packageG/pages/member/extension/extension",
      });
    },
    onChange(event) {
      this.setData({
        activeNames: !this.data.activeNames,
      });
    },
    gotoUrl(e) {
      let url = e.currentTarget.dataset.item.h5_link;
      try {
        wx.navigateTo({
          url: url,
        });
      } catch (e) {
        wx.showToast({
          title: "链接设置错误",
          icon: "none",
          duration: 2000,
        });
      }
    },
  },
});
